package com.ny.view;

import com.ny.entity.Product;
import com.ny.service.ProductService;
import com.ny.service.impl.ProductServiceImpl;

import java.sql.SQLException;
import java.util.Scanner;

public class ProductView {
    private ProductService uer2 = new ProductServiceImpl();
    Product product = new Product();
    public ProductView() throws SQLException, ClassNotFoundException {
    }

    public void showAddProductForm() throws SQLException, ClassNotFoundException {
        System.out.println("请输入商品名称：");
        Scanner scanner= new Scanner(System.in);
        String name = scanner.next();
        System.out.println("请输入商品价格：");
        double price = scanner.nextDouble();
        System.out.println("请输入商品数量：");
        int num = scanner.nextInt();
        System.out.println("请输入商品类型：");
        String type = scanner.next();
        System.out.println("请输入商品描述：");
        String desc = scanner.next();
        product.setName(name);
        product.setPrice(price);
        product.setStock(num);
        product.setCategory(type);
        product.setDescription(desc);
        uer2.updateProduct(product);

    }

    public void showUpdateProductForm() throws SQLException, ClassNotFoundException {
        System.out.println("请输入商品名称：");
        Scanner sc = new Scanner(System.in);
        String name = sc.next();
        System.out.println("请输入商品价格：");
        double price = sc.nextDouble();
        System.out.println("请输入商品数量：");
        int num = sc.nextInt();
        System.out.println("请输入商品类型：");
        String type = sc.next();
        System.out.println("请输入商品描述：");
        String desc = sc.next();
        product.setName(name);
        product.setPrice(price);
        product.setStock(num);
        product.setCategory(type);
        product.setDescription(desc);
        uer2.updateProduct(product);
    }
}
